package com.view;

import javax.swing.*;
import java.awt.*;

public class RSPWindow extends JFrame{
    private JPanel jPanel;
    private JComboBox jComboBox1;
    private JComboBox jComboBox2;


    public RSPWindow(String title) throws HeadlessException {
        super(title);
        setSize(500, 600);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        init();
    }

    private void  init(){
        BorderLayout borderLayout = new BorderLayout();

        // 创建内容面包容器，指定使用 边界布局
        jPanel = new JPanel(borderLayout);

        //下拉列表框1
        String[] listData1 = new String[]{"player1", "player2", "player3"};
        jComboBox1 = new JComboBox<>(listData1);

        //下拉列表框2
        String[] listData2 = new String[]{"person", "computer"};
        jComboBox2 = new JComboBox<>(listData2);

        //标签
        JLabel label = new JLabel("RockPaperScissors");

        // 创建 5 个按钮
        JButton btnN = new JButton("RockPaperScissors");
        JButton btnS = new JButton("PlayAgain");
        //JButton btnW = new JButton("player1");
        //JButton btnE = new JButton("Button_East");
        JButton btnC = new JButton("PK");

        // 把 5 个按钮添加到容器中的 5 个方位
        jPanel.add(label, BorderLayout.NORTH);
        jPanel.add(btnS, BorderLayout.SOUTH);
        jPanel.add(jComboBox1, BorderLayout.WEST);
        jPanel.add(jComboBox2, BorderLayout.EAST);
        jPanel.add(btnC, BorderLayout.CENTER);

        setContentPane(jPanel);
    }

}
